package com.wanmait.recycle.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.recycle.mapper.CommentMapper;
import com.wanmait.recycle.pojo.Comment;
import com.wanmait.recycle.service.CommentService;
import com.wanmait.recycle.service.ConfigService;
import com.wanmait.recycle.util.PageContext;
import com.wanmait.recycle.util.Pager;

@Service
@Transactional
public class CommentServiceImpl implements CommentService {

	@Resource
	private CommentMapper commentMapper; 
	@Resource
	private ConfigService configService; 
	
	
	@Override
	public void insert(Comment object) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(Comment object) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(Integer id) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(String ids) {
		// TODO Auto-generated method stub

	}

	@Override
	public Comment findById(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Comment> findAll() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int getDataCount() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<Comment> findAll(Pager pager) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Comment> findAll(Comment object) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int getDataCount(Comment object) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<Comment> findAll(Pager pager, Comment object) {
		// TODO Auto-generated method stub
		return null;
	}

	/*根据文章id查询所有评论  ZQ*/
	@Override
	public PageInfo<Comment> findCommentByArticleId(Integer id) {
		Map<String, Map<String,String>> config = configService.findAllConfig();
		PageHelper.startPage(PageContext.getPageNum(), Integer.parseInt(config.get("评论分页").get("webComment")));
		List<Comment> comments = commentMapper.findByArticle(id);
		PageInfo<Comment> pageInfo = new PageInfo<Comment>(comments,7);
		return pageInfo;
	}

	/*添加一级评论 ZQ */
	@Override
	public void addFirstComment(Comment comment) {
		commentMapper.addFirstComment(comment);
		
	}

	/*添加二级评论*/
	@Override
	public void addSecondComment(Comment comment) {
		commentMapper.addSecondComment(comment);
		
	}

}
